<template>
  <div class="container-big">
    <div class="header-top">
      <div class="head-title" @click="gotoPage()">
        <div class="backIcon"><i class="el-icon-back"></i></div>不准打广告-数据
      </div>
    </div>
    <div class="container-right">
      <div class="number-big">
        <div class="number">今日打标签客户数：<span>2</span></div>
        <div class="number">累计打标签客户数：<span>2</span></div>
      </div>
      <div class="content-big">
        <div class="formGroup">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="130px" class="">
            <el-form-item prop="userName2">
              <div class="search">
                <el-input v-model="queryParams.userName1" size="small" placeholder="搜索客户昵称" clearable/>
                <el-button icon="el-icon-search" size="small" @click="handleQuery"></el-button>
              </div>
            </el-form-item>
            <el-form-item prop="userName2">
              <div class="search">
                <el-input v-model="queryParams.userName1" size="small" placeholder="搜索搜索关键词" clearable/>
                <el-button icon="el-icon-search" size="small" @click="handleQuery"></el-button>
              </div>
            </el-form-item>
            <el-form-item v-model="queryParams.userName2">
              <el-date-picker
                v-model="dateRange1"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="-"
                size="small"
                start-placeholder="触发开始时间"
                end-placeholder="触发结束时间"
                @change="handleQuery"
              ></el-date-picker>
            </el-form-item>
            <el-form-item prop="userName2">
              <multipleSelect size="small" placeholder='企微标签' :receiverNameOpt='lableOpt' />
            </el-form-item>
            <el-form-item prop="userName2">
              <multipleSelect size="small" placeholder='智能标签' :receiverNameOpt='lableOpt' />
            </el-form-item>
            <el-form-item prop="userName2">
            </el-form-item>
          </el-form>
        </div>
        <div class="content-tabel">
          <el-table
            :data="tableDataList"
            ref="companylabelList"
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              :label="item.label"
              align="center"
              v-for="(item, index) in tableColumns"
              :key="index"
              :prop="item.key"
              :min-width="item.minWidth ? item.minWidth : ``"
              :fixed="item.fixed ? item.fixed : false"
              :show-overflow-tooltip="true"
            >
              <!--用于表格自定义-->
              <template slot-scope="scope">
                <div v-if="item.key=='name'">
                  下班时间更改
                </div>
                <div class="label-list" v-else-if="item.key=='label'">
                  <span>未入VIP群</span>
                  <span>持续7天未发言</span>
                  <span>1000</span>
                </div>
                <div class="label-list" v-else-if="item.key=='label2'">
                  <span>未入VIP群</span>
                  <span>持续7天未发言</span>
                  <span>1000</span>
                </div>
                <div v-else-if="item.key=='label3'" class="keywordList">
                  <span>可爱</span>，
                  <span>重要</span>

                  <el-tooltip placement="top" effect="light">
                    <div slot="content" class="tooltipContent">
                      <div class="h5">对话中出现以下全部模糊关键词：</div>
                      <div class="list-big">
                        <span>可爱</span>
                        <span>重要</span>
                      </div>

                    </div>
                    <div class="tips">【细则】</div>
                  </el-tooltip>
                </div>
                <div v-else style="text-align: center">{{ scope.row[item.key] }}</div>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </div>
      </div>
    </div>
    <!--    添加编辑规则-->
    <addOrEditRule v-if="showAddOrEditRule" :visableIf.sync="showAddOrEditRule" :dialogType="dialogType"></addOrEditRule>
  </div>
</template>

<script>
import {listUser, delUser,} from "@/api/system/user";
export default {
  name: "keywordList",
  components: {
    'addOrEditRule': () => import('./addOrEditRule.vue'),
    'multipleSelect': () => import('@/views/components/multipleSelect.vue'),


  },
  data() {
    return {
      showAddOrEditRule: false,//添加编辑规则
      showSetRrulescheme: false,//设置
      showApplicationPage: false,//应用
      active: 0,
      dialogType: 'add',
      dateRange1:[],
      lableOpt: [
        {value: 1, label: '客户等级', children: [
            {value: 3, label: '核心',},
            {value: 4, label: '重要',},
            {value: 5, label: '一般',}
          ]
        },
        {value: 2, label: '客户等级2', children: [
            {value: 6, label: '可爱',},
            {value: 7, label: '知性',},
            {value: 8, label: '性感',}
          ]}
      ],
      showExportPage: false,//导出
      tableHeight: 600,
      tableColumns: [
        {key: 'name', label: `客户昵称`, visible: true, minWidth: 150, fixed: true},
        {key: 'label', label: `企微标签`, visible: true, minWidth: 150, fixed: false},
        {key: 'label2', label: `智能标签`, visible: true, minWidth: 150, fixed: false},
        {key: 'label3', label: `触发关键词`, visible: true, minWidth: 150, fixed: false},
        {key: 'label4', label: `触发时间`, visible: true, minWidth: 150, fixed: false},
      ],
      tableDataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: null,//用户id
        userName1: null,

      },
      total: 8, // 表格的总条数
    };
  },
  created() {
    // this.getList();
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        label1: '18207418337',
        label2: '18207418337',
        label3: '18207418337',
        label4: '2023-03-12',
        label5: '18207418337',
        label6: '18207418337',
        status:0,
      }
      this.tableDataList.push(obj);
    }
  },
  methods: {
    gotoPage(){
      this.$router.push({
        path:'SingleKeywordList',
      })
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
  }
};
</script>
<style lang="scss" scoped>
.tooltipContent {
  .h5 {
    font-size: 12px;
  }

  .list-big {
    display: flex;
    flex-wrap: wrap;

    span {
      height: 25px;
      display: flex;
      padding: 0px 5px;
      margin: 4px 4px 4px 0;
      color: rgba(0, 0, 0, .65);
      border: 1px dashed #eee;
    }
  }
}

.keywordList {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;

  .tips {
    color: #2d8cf0;
  }
}

.container-big {
  display: flex;
  height: calc(100vh - 50px);

  flex-direction: column;

  .container-left {
    width: 278px;
    background: #fff;
    margin-right: 12px;
    padding: 20px;
    position: relative;

    .addIcon {
      position: absolute;
      right: 10px;
      top: 26px;

      i {
        margin: 0px 5px;
        font-size: 16px;
        font-weight: bold;
      }
    }

    .line {
      margin: 10px -20px;
      height: 1px;
      background: #eee;

    }

    .tablist {
      height: 50px;
      display: flex;
      justify-items: center;
      border-left: none;
      border-radius: 4px 0 0 4px;
      height: 32px;
      margin-bottom: 12px;
      position: relative;

      &:after {
        content: '';
        position: absolute;
        left: -40px;
        right: -40px;
        bottom: 0px;

      }

      li {
        display: flex;
        align-items: center;
        justify-items: center;
        border-left: 1px solid #e9e9e9;
        border-radius: 4px 0 0 4px;
        font-weight: bold;
        padding: 0px 10px;
        font-size: 14px;
        color: rgba(0, 0, 0, .65);
        border: 1px solid #eee;
        cursor: pointer;

        &.active {
          border-color: #3070ff;
          color: #3070ff;
        }
      }
    }
  }

  .container-right {
    flex: 1;
    margin: 12px;
    overflow-y: auto;
  }
}


.content-big {
  height:100%;
  overflow-y: auto;
  background: #fff;

  .el-form {
    background: #fff;
    border-radius: 8px;
    margin-top: -1px;

    .el-button {
      margin-right: 10px;
    }

    .el-form-item {
      margin-bottom: 0px;

      .right-big {
        border-radius: 4px;
        border: 1px solid #DCDFE6;
        padding-left: 11px;

        > span {
          color: #777;
          width: 89px;
          display: inline-block;
          white-space: nowrap;
        }

        .el-select {
          width: 138px;

          ::v-deep .el-input__inner {
            border: none;
          }
        }

        .el-input {
          width: 138px;

          ::v-deep .el-input__inner {
            border: none;
          }
        }

        ::v-deep .el-date-editor {
          border: none;
        }
      }

    }
  }

  .content-tabel {
    background: #fff;

    .content-head {
      height: 60px;
      display: flex;
      justify-content: space-between;
      padding: 16px;

      .content-left {
        display: flex;
        align-items: center;

        .el-button {
          .el-button--medium {
            padding: 8px 20px;
          }
        }

        .left-number {
          font-size: 12px;
          color: rgba(0, 0, 0, .45);
          margin-left: 10px;
        }

        .group-btn {

        }
      }

      .content-right {
        display: flex;
        align-items: center;

        .example {
          font-size: 14px;
          display: flex;
          align-items: center;
          margin-right: 20px;

          .el-switch {
            margin-right: 10px;
            margin-left: 5px;
          }
        }
      }
    }

    .el-table {
      margin-bottom: 20px;
    }
  }

  .pagination-container {
    height: 60px;
  }
}

.table-footer {
  position: fixed;
  left: 500px;
  right: 12px;
  bottom: 0;
  height: 56px;
  padding: 12px 16px;
  border-top: 1px solid #e9e9e9;
  background: #fff;
  z-index: 2;
  display: flex;
  justify-content: space-between;

  .footer-left {
    display: flex;
    align-items: center;

    .chooseAll {
      color: #5993ff;
      margin-right: 10px;
    }

    span {
      margin: 0px 10px;
      color: #5993ff;
    }
  }

  .footer-right {
    .el-dropdown {
      margin-right: 10px;

      .el-button--primary {
        border-radius: 4px;
        color: rgba(0, 0, 0, .65);
        border: 1px solid #e9e9e9;
        background: #fff;
      }
    }
  }
}

.userInfo {
  border-radius: 4px;
  margin: 8px 0;
  cursor: pointer;
  position: relative;
  padding-left: 50px;
  font-size: 14px;
  list-style: none;
  text-align: left;

  img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    left: 0px;
    top: 0px;
    position: absolute;
  }

  .label {
    margin-top: 2px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.label-list {
  label {
    font-size: 14px;
    line-height: 1.5715;
    word-wrap: break-word;
    font-weight: 400;
  }

  span {
    margin: 4px 4px 4px 0;
    font-size: 12px;
    height: 25px;
    line-height: 25px;
    white-space: nowrap;
    background: #f0f0f0;
    border: 1px solid #e9e9e9;
    border-radius: 4px;
    padding: 0px 7px;
    display: inline-block;

  }
}
.formGroup {
  padding: 10px;
}
.search {
  display: flex;

  ::v-deep.el-input__inner {
    border-right: none !important;
    border-radius: 4px 0px 0px 0px;
  }

  ::v-deep .el-button--default {
    border-radius: 0px 4px 4px 0px;
    padding: 0px 10px;
  }
}
.content {
  width: 400px;
  height: auto;
}
.total-big {
  display: flex;
  flex-direction: column;
  .dayTotal {
    span {
      color: #f8ac59;
      font-weight: bold;
    }
  }
  .allTotal {
    span {
      font-weight: bold;
    }
  }
}
.status {
  span {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 100%;
    margin-right: 5px;

    &.green {
      background: #00DD33;
    }

    &.red {
      background: red;
    }

    &.glay {
      background: #8C8C8C;
    }
  }
}
.number-big {
  padding: 20px;
  background: #fff;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 4px;
  font-size: 14px;
  .number {
    margin-right: 30px;
    &:first-child{
      span {
        color: #f8ac59;
      }
    }
    span {
      font-size:18px;
      font-weight: bold;
    }
  }

}
.header-top {
  height: 46px;
  background: #fff;
  border-bottom: 1px solid #e9e9e9;
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 20px;

  .head-title {
    font-size: 14px;
    line-height: 22px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    font-weight: bold;
    .backIcon {
      display: flex;
      align-items: center;
      padding: 0;
      margin-right: 12px;
      border: none;
      width: 24px;
      height: 24px;
      background: #4b5a95;
      border-radius: 12px;
      cursor: pointer;
      justify-content: center;
      font-weight: 400;
    }
    i {
      font-size: 16px;
      font-weight: bold;
      cursor: pointer;
      color: #fff;
    }
  }

}
</style>
